// --------------------------------------------------------------------------------------------------------------------
// <copyright file="UIAbstractVirtualGrid.cs" company="Open Trader">
//   Copyright (c) David Denis (david.denis@systemathics.com)
// </copyright>
// <summary>
//   |  Open Trader - The Open Source Systematic Trading Platform
//   |
//   |  This program is free software: you can redistribute it and/or modify
//   |  it under the terms of the GNU General Public License as published by
//   |  the Free Software Foundation, either version 2 of the License, or
//   |  (at your option) any later version.
//   |
//   |  This program is distributed in the hope that it will be useful,
//   |  but WITHOUT ANY WARRANTY; without even the implied warranty of
//   |  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//   |  GNU General Public License for more details.
//   |
//   |  You should have received a copy of the GNU General Public License
//   |  along with this program.  If not, see http://www.gnu.org/licenses
//   |
//   |  Up to date informations about Open Trader can be found at :
//   |    http://opentrader.org
//   |    http://opentrader.codeplex.com
//   |
//   |  For professional services, please visit us at :
//   |    http://www.systemathics.com
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace Org.OpenTrader.Framework.UI.Forms
{
    #region Using Directives

    using System.ComponentModel;
    using System.Windows.Forms;

    #endregion

    /// <summary>
    /// The custom data grid view.
    /// </summary>
    public abstract class UIAbstractDataGridView : DataGridView
    {
        #region Constructors and Destructors

        /// <summary>
        /// Initializes a new instance of the <see cref="UIAbstractDataGridView"/> class.
        /// </summary>
        public UIAbstractDataGridView()
        {
            base.VirtualMode = true;
            base.MultiSelect = false;
            base.ReadOnly = true;

            base.BorderStyle = System.Windows.Forms.BorderStyle.None;
            base.EditMode = System.Windows.Forms.DataGridViewEditMode.EditOnKeystrokeOrF2;
            base.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.CellSelect;

            base.AllowUserToAddRows = false;
            base.AllowUserToDeleteRows = false;
            base.AllowUserToOrderColumns = true;
            base.AllowUserToResizeColumns = false;
            base.AllowUserToResizeRows = false;

            base.ShowCellErrors = false;
            base.ShowCellToolTips = true;
            base.ShowEditingIcon = false;
            base.ShowRowErrors = false;

            base.DefaultCellStyle.BackColor = UIDefaults.GridCellBackground;
            base.DefaultCellStyle.ForeColor = UIDefaults.GridCellForeground;
            base.DefaultCellStyle.Font = UIDefaults.GridCellFont;
            base.CellBorderStyle = DataGridViewCellBorderStyle.Raised;

            base.ColumnHeadersDefaultCellStyle.BackColor = UIDefaults.GridHeaderBackground;
            base.ColumnHeadersDefaultCellStyle.ForeColor = UIDefaults.GridHeaderForeground;
            base.ColumnHeadersDefaultCellStyle.Font = UIDefaults.GridHeaderFont;
            base.ColumnHeadersBorderStyle = DataGridViewHeaderBorderStyle.Raised;
            base.ColumnHeadersHeight = 23;
            base.ColumnHeadersVisible = true;
            base.ColumnHeadersHeightSizeMode =
                System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing;

            base.RowHeadersWidth = 24;
            base.RowHeadersWidthSizeMode = DataGridViewRowHeadersWidthSizeMode.DisableResizing;
            base.RowHeadersVisible = true;
            base.EnableHeadersVisualStyles = false;
        }

        #endregion

        #region Properties

        /// <summary>
        /// Gets a value indicating whether AllowUserToAddRows.
        /// </summary>
        [Category("UI Virtual Grid")]
        [ReadOnly(true)]
        public new bool AllowUserToAddRows
        {
            get
            {
                return base.AllowUserToAddRows;
            }
        }

        /// <summary>
        /// Gets a value indicating whether AllowUserToDeleteRows.
        /// </summary>
        [Category("UI Virtual Grid")]
        [ReadOnly(true)]
        public new bool AllowUserToDeleteRows
        {
            get
            {
                return base.AllowUserToDeleteRows;
            }
        }

        /// <summary>
        /// Gets a value indicating whether AllowUserToOrderColumns.
        /// </summary>
        [Category("UI Virtual Grid")]
        [ReadOnly(true)]
        public new bool AllowUserToOrderColumns
        {
            get
            {
                return base.AllowUserToOrderColumns;
            }
        }

        /// <summary>
        /// Gets a value indicating whether AllowUserToResizeColumns.
        /// </summary>
        [Category("UI Virtual Grid")]
        [ReadOnly(true)]
        public new bool AllowUserToResizeColumns
        {
            get
            {
                return base.AllowUserToResizeColumns;
            }
        }

        /// <summary>
        /// Gets a value indicating whether AllowUserToResizeRows.
        /// </summary>
        [Category("UI Virtual Grid")]
        [ReadOnly(true)]
        public new bool AllowUserToResizeRows
        {
            get
            {
                return base.AllowUserToResizeRows;
            }
        }

        /// <summary>
        /// Gets AlternatingRowsDefaultCellStyle.
        /// </summary>
        [Category("UI Virtual Grid")]
        [ReadOnly(true)]
        [Browsable(false)]
        public new DataGridViewCellStyle AlternatingRowsDefaultCellStyle
        {
            get
            {
                return base.AlternatingRowsDefaultCellStyle;
            }
        }

        /// <summary>
        /// Gets BorderStyle.
        /// </summary>
        [Category("UI Virtual Grid")]
        [ReadOnly(true)]
        public new BorderStyle BorderStyle
        {
            get
            {
                return base.BorderStyle;
            }
        }

        /// <summary>
        /// Gets CellBorderStyle.
        /// </summary>
        [Category("UI Virtual Grid")]
        [ReadOnly(true)]
        public new DataGridViewCellBorderStyle CellBorderStyle
        {
            get
            {
                return base.CellBorderStyle;
            }
        }

        /// <summary>
        /// Gets ColumnHeadersBorderStyle.
        /// </summary>
        [Category("UI Virtual Grid")]
        [ReadOnly(true)]
        public new DataGridViewHeaderBorderStyle ColumnHeadersBorderStyle
        {
            get
            {
                return base.ColumnHeadersBorderStyle;
            }
        }

        /// <summary>
        /// Gets ColumnHeadersDefaultCellStyle.
        /// </summary>
        [Category("UI Virtual Grid")]
        [ReadOnly(true)]
        [Browsable(false)]
        public new DataGridViewCellStyle ColumnHeadersDefaultCellStyle
        {
            get
            {
                return base.ColumnHeadersDefaultCellStyle;
            }
        }

        /// <summary>
        /// Gets ColumnHeadersHeight.
        /// </summary>
        [Category("UI Virtual Grid")]
        [ReadOnly(true)]
        public new int ColumnHeadersHeight
        {
            get
            {
                return base.ColumnHeadersHeight;
            }
        }

        /// <summary>
        /// Gets ColumnHeadersHeightSizeMode.
        /// </summary>
        [Category("UI Virtual Grid")]
        [ReadOnly(true)]
        public new DataGridViewColumnHeadersHeightSizeMode ColumnHeadersHeightSizeMode
        {
            get
            {
                return base.ColumnHeadersHeightSizeMode;
            }
        }

        /// <summary>
        /// Gets or sets a value indicating whether ColumnHeadersVisible.
        /// </summary>
        [Category("UI Virtual Grid")]
        public new bool ColumnHeadersVisible
        {
            get
            {
                return base.ColumnHeadersVisible;
            }

            set
            {
                base.ColumnHeadersVisible = value;
            }
        }

        /// <summary>
        /// Gets DefaultCellStyle.
        /// </summary>
        [Category("UI Virtual Grid")]
        [ReadOnly(true)]
        [Browsable(false)]
        public new DataGridViewCellStyle DefaultCellStyle
        {
            get
            {
                return base.DefaultCellStyle;
            }
        }

        /// <summary>
        /// Gets EditMode.
        /// </summary>
        [Category("UI Virtual Grid")]
        [ReadOnly(true)]
        public new DataGridViewEditMode EditMode
        {
            get
            {
                return base.EditMode;
            }
        }

        /// <summary>
        /// Gets a value indicating whether EnableHeadersVisualStyles.
        /// </summary>
        [Category("UI Virtual Grid")]
        [ReadOnly(true)]
        public new bool EnableHeadersVisualStyles
        {
            get
            {
                return base.EnableHeadersVisualStyles;
            }
        }

        /// <summary>
        /// Gets a value indicating whether MultiSelect.
        /// </summary>
        [Category("UI Virtual Grid")]
        [ReadOnly(true)]
        public new bool MultiSelect
        {
            get
            {
                return base.MultiSelect;
            }
        }

        /// <summary>
        /// Gets a value indicating whether ReadOnly.
        /// </summary>
        [Category("UI Virtual Grid")]
        [ReadOnly(true)]
        public new bool ReadOnly
        {
            get
            {
                return base.ReadOnly;
            }
        }

        /// <summary>
        /// Gets RowHeadersBorderStyle.
        /// </summary>
        [Category("UI Virtual Grid")]
        [ReadOnly(true)]
        public new DataGridViewHeaderBorderStyle RowHeadersBorderStyle
        {
            get
            {
                return base.RowHeadersBorderStyle;
            }
        }

        /// <summary>
        /// Gets RowHeadersDefaultCellStyle.
        /// </summary>
        [Category("UI Virtual Grid")]
        [ReadOnly(true)]
        [Browsable(false)]
        public new DataGridViewCellStyle RowHeadersDefaultCellStyle
        {
            get
            {
                return base.RowHeadersDefaultCellStyle;
            }
        }

        /// <summary>
        /// Gets or sets a value indicating whether RowHeadersVisible.
        /// </summary>
        [Category("UI Virtual Grid")]
        public new bool RowHeadersVisible
        {
            get
            {
                return base.RowHeadersVisible;
            }

            set
            {
                base.RowHeadersVisible = value;
            }
        }

        /// <summary>
        /// Gets RowHeadersWidth.
        /// </summary>
        [Category("UI Virtual Grid")]
        [ReadOnly(true)]
        public new int RowHeadersWidth
        {
            get
            {
                return base.RowHeadersWidth;
            }
        }

        /// <summary>
        /// Gets RowHeadersWidthSizeMode.
        /// </summary>
        [Category("UI Virtual Grid")]
        [ReadOnly(true)]
        [Browsable(false)]
        public new DataGridViewRowHeadersWidthSizeMode RowHeadersWidthSizeMode
        {
            get
            {
                return base.RowHeadersWidthSizeMode;
            }
        }

        /// <summary>
        /// Gets RowsDefaultCellStyle.
        /// </summary>
        [Category("UI Virtual Grid")]
        [ReadOnly(true)]
        [Browsable(false)]
        public new DataGridViewCellStyle RowsDefaultCellStyle
        {
            get
            {
                return base.RowsDefaultCellStyle;
            }
        }

        /// <summary>
        /// Gets RowTemplate.
        /// </summary>
        [Category("UI Virtual Grid")]
        [ReadOnly(true)]
        [Browsable(false)]
        public new DataGridViewRow RowTemplate
        {
            get
            {
                return base.RowTemplate;
            }
        }

        /// <summary>
        /// Gets SelectionMode.
        /// </summary>
        [Category("UI Virtual Grid")]
        [ReadOnly(true)]
        public new DataGridViewSelectionMode SelectionMode
        {
            get
            {
                return base.SelectionMode;
            }
        }

        /// <summary>
        /// Gets a value indicating whether ShowCellErrors.
        /// </summary>
        [Category("UI Virtual Grid")]
        [ReadOnly(true)]
        public new bool ShowCellErrors
        {
            get
            {
                return base.ShowCellErrors;
            }
        }

        /// <summary>
        /// Gets a value indicating whether ShowCellToolTips.
        /// </summary>
        [Category("UI Virtual Grid")]
        [ReadOnly(true)]
        public new bool ShowCellToolTips
        {
            get
            {
                return base.ShowCellToolTips;
            }
        }

        /// <summary>
        /// Gets a value indicating whether ShowEditingIcon.
        /// </summary>
        [Category("UI Virtual Grid")]
        [ReadOnly(true)]
        public new bool ShowEditingIcon
        {
            get
            {
                return base.ShowEditingIcon;
            }
        }

        /// <summary>
        /// Gets a value indicating whether ShowRowErrors.
        /// </summary>
        [Category("UI Virtual Grid")]
        [ReadOnly(true)]
        public new bool ShowRowErrors
        {
            get
            {
                return base.ShowRowErrors;
            }
        }

        /// <summary>
        /// Gets a value indicating whether VirtualMode.
        /// </summary>
        [Category("UI Virtual Grid")]
        [ReadOnly(true)]
        public new bool VirtualMode
        {
            get
            {
                return base.VirtualMode;
            }
        }

        #endregion

        #region Methods

        /// <summary>
        /// The set selected cell core.
        /// </summary>
        /// <param name="columnIndex">
        /// The column index.
        /// </param>
        /// <param name="rowIndex">
        /// The row index.
        /// </param>
        /// <param name="selected">
        /// The selected.
        /// </param>
        protected override void SetSelectedCellCore(int columnIndex, int rowIndex, bool selected)
        {
            // Disable selection
            // base.SetSelectedCellCore(columnIndex, rowIndex, selected);
        }

        /// <summary>
        /// The set selected row core.
        /// </summary>
        /// <param name="rowIndex">
        /// The row index.
        /// </param>
        /// <param name="selected">
        /// The selected.
        /// </param>
        protected override void SetSelectedRowCore(int rowIndex, bool selected)
        {
            // Disable selection
        }

        /// <summary>
        /// The initialize component.
        /// </summary>
        private void InitializeComponent()
        {
            ((System.ComponentModel.ISupportInitialize)this).BeginInit();
            this.SuspendLayout();

            // UIAbstractDataGridView
            ((System.ComponentModel.ISupportInitialize)this).EndInit();
            this.ResumeLayout(false);
        }

        #endregion
    }
}